/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package ms.jasim.model.items.impl;

import ms.jasim.model.impl.NamedModelObjectImpl;
import ms.jasim.model.impl.ModelObjectImpl;
import ms.jasim.model.items.Item;
import ms.jasim.model.items.ItemsPackage;
import ms.jasim.model.items.PropertyDescriptor;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Property Descriptor</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.jasim.model.items.impl.PropertyDescriptorImpl#getPddlPredicate <em>Pddl Predicate</em>}</li>
 *   <li>{@link ms.jasim.model.items.impl.PropertyDescriptorImpl#getItem <em>Item</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PropertyDescriptorImpl extends NamedModelObjectImpl implements PropertyDescriptor {
	/**
	 * The default value of the '{@link #getPddlPredicate() <em>Pddl Predicate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPddlPredicate()
	 * @generated
	 * @ordered
	 */
	protected static final String PDDL_PREDICATE_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getPddlPredicate() <em>Pddl Predicate</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPddlPredicate()
	 * @generated
	 * @ordered
	 */
	protected String pddlPredicate = PDDL_PREDICATE_EDEFAULT;

	/**
	 * The cached value of the '{@link #getItem() <em>Item</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getItem()
	 * @generated
	 * @ordered
	 */
	protected Item item;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PropertyDescriptorImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ItemsPackage.Literals.PROPERTY_DESCRIPTOR;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getPddlPredicate() {
		return pddlPredicate;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPddlPredicate(String newPddlPredicate) {
		String oldPddlPredicate = pddlPredicate;
		pddlPredicate = newPddlPredicate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ItemsPackage.PROPERTY_DESCRIPTOR__PDDL_PREDICATE, oldPddlPredicate, pddlPredicate));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Item getItem() {
		return item;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetItem(Item newItem, NotificationChain msgs) {
		Item oldItem = item;
		item = newItem;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ItemsPackage.PROPERTY_DESCRIPTOR__ITEM, oldItem, newItem);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setItem(Item newItem) {
		if (newItem != item) {
			NotificationChain msgs = null;
			if (item != null)
				msgs = ((InternalEObject)item).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ItemsPackage.PROPERTY_DESCRIPTOR__ITEM, null, msgs);
			if (newItem != null)
				msgs = ((InternalEObject)newItem).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ItemsPackage.PROPERTY_DESCRIPTOR__ITEM, null, msgs);
			msgs = basicSetItem(newItem, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ItemsPackage.PROPERTY_DESCRIPTOR__ITEM, newItem, newItem));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ItemsPackage.PROPERTY_DESCRIPTOR__ITEM:
				return basicSetItem(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ItemsPackage.PROPERTY_DESCRIPTOR__PDDL_PREDICATE:
				return getPddlPredicate();
			case ItemsPackage.PROPERTY_DESCRIPTOR__ITEM:
				return getItem();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ItemsPackage.PROPERTY_DESCRIPTOR__PDDL_PREDICATE:
				setPddlPredicate((String)newValue);
				return;
			case ItemsPackage.PROPERTY_DESCRIPTOR__ITEM:
				setItem((Item)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ItemsPackage.PROPERTY_DESCRIPTOR__PDDL_PREDICATE:
				setPddlPredicate(PDDL_PREDICATE_EDEFAULT);
				return;
			case ItemsPackage.PROPERTY_DESCRIPTOR__ITEM:
				setItem((Item)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ItemsPackage.PROPERTY_DESCRIPTOR__PDDL_PREDICATE:
				return PDDL_PREDICATE_EDEFAULT == null ? pddlPredicate != null : !PDDL_PREDICATE_EDEFAULT.equals(pddlPredicate);
			case ItemsPackage.PROPERTY_DESCRIPTOR__ITEM:
				return item != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (PddlPredicate: ");
		result.append(pddlPredicate);
		result.append(')');
		return result.toString();
	}

	
	@Override
	public String getName() {
		return getItem() != null? getItem().getName(): null;
	}

	
	@Override
	public void setName(String value) {
		if (getItem() != null)
			getItem().setName(value);
	}

} //PropertyDescriptorImpl
